import Foundation

public class Node<Value: Equatable> {
    public var value: Value
    public var next: Node? = .none
    public init(value: Value, next: Node? = .none) {
        self.value = value
        self.next = next
    }
}

extension Node: CustomStringConvertible {
    public var description: String {
        guard let next = next else { return "\(value)" }
        return "\(value) -> " + String(describing: next) + " "
    }
}

extension Node: Equatable {
    public static func == (lhs: Node<Value>, rhs: Node<Value>) -> Bool {
        return lhs.value == rhs.value
    }
}
